package edu.pw.p2pclient.networking.messages;

import java.util.ArrayList;

import edu.pw.p2pclient.data.Node;
import edu.pw.p2pclient.data.Resource;
import edu.pw.p2pclient.logic.SharedManager;

public class ResourceListResponse extends Message {

	private static final long serialVersionUID = 7369018545770898991L;

	private long mResourcesVersion;
	private ArrayList<Resource> mResources;

	public ResourceListResponse() {
		super(MsgType.RESOURCE_LIST_RESPONSE);
		mResourcesVersion = SharedManager.getInstance().getListVersion();

		mResources = new ArrayList<Resource>();
		ArrayList<Node> nodes = SharedManager.getInstance().getAllShared();
		for (Node node : nodes)
			mResources.add(new Resource(node));
	}

	public long getResourcesVersion() {
		return mResourcesVersion;
	}

	public ArrayList<Resource> getResources() {
		return mResources;
	}

}
